package com.example.mr5.mygame.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by Mr.5
 * Date：2016/5/7.
 * Time：21:20
 */
public class SharePreferenceUtil {
    private SharedPreferences sp;
    private SharedPreferences.Editor editor;

    public SharePreferenceUtil(Context context) {
        sp = context.getSharedPreferences("MyGame", context.MODE_PRIVATE);
        editor = sp.edit();
    }

    public void setScore(int s){
        editor.putInt("score",s);
        editor.commit();
    }

    public int getScore(){
        return sp.getInt("score",0);
    }

    public void setFirstBattleGame(boolean b){
        editor.putBoolean("first", b);
        editor.commit();
    }

    public boolean getFistBattleGame(){
        return sp.getBoolean("first", true);
    }


    public void setBiggistNum(int num){
        editor.putInt("biggist", num);
        editor.commit();
    }
    public int getBiggistNum(){
        return sp.getInt("biggist", 0);
    }


    public void setShowAd(String showAd){
        editor.putString("showAd", showAd);
        editor.commit();
    }

    public String getShowAd(){
        return sp.getString("showAd", "no");
    }

    public void setCostScore1(String s){
        editor.putString("costScore1",s);
        editor.commit();
    }

    public String getCostScore1(){
        return sp.getString("costScore1","100");
    }

    public void setCostScore2(String s){
        editor.putString("costScore2",s);
        editor.commit();
    }

    public String getCostScore2(){
        return sp.getString("costScore2","30");
    }

    // 是否第一次运行本应用
    public void setIsFirst(boolean isFirst) {
        editor.putBoolean("isFirst", isFirst);
        editor.commit();
    }

    public boolean getisFirst() {
        return sp.getBoolean("isFirst", true);
    }
}
